package gmusic.command;

import gmusic.mb.bo.ArtistMBBean;
import gmusic.mb.bo.ReleaseMBBean;
import gmusic.mb.services.impl.MusicBrainzServicesImpl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class AfficherReleasesMB implements Command {

	/*
	 * private final static Logger log = Logger
	 * .getLogger(AfficherReleasesMB.class);
	 */

	public String execute(HttpServletRequest req) throws Exception {

		HttpSession session = req.getSession();

		String mbid = req.getParameter("mbid");

		ArtistMBBean currentArtist = MusicBrainzServicesImpl.getInstance()
				.getArtist(mbid);
		List<ReleaseMBBean> releases = MusicBrainzServicesImpl.getInstance()
				.getReleasesAndTracks(mbid);

		session.setAttribute("releases", releases);
		session.setAttribute("currentArtist", currentArtist);

		return "/afficherReleasesMB.jsp";
	}
}
